@extends('home.layout')

@section('topbanner')

@endsection

@section('content')
    <div class="m-tab">
        <div class="m-title">
            <a href="{{ $currentUrl }}">
                <h3>{{ $pCategoryDetail->title }}</h3></a>
            <div class="btn">
                @foreach($data as $key=>$value)
                    @if($key < 8)
                        <a href="{{ get_home_url($value->document_type.'/detail/'.$value->id) }}">{{ $value->title }}</a>
                    @endif
                @endforeach
            </div>
        </div>
        <div class="m-context">
            <div class="w1002 f-oh">
                <ul class="m-lst">
                    @include('home.'.$template.'_list')
                    <span class="nopic"></span>
                    <!-- li class="nopic"><a href="javascript:void(0);" id="loadmore"><img src="images/morepic.jpg" width="200" height="253" alt=""></a></li -->
                </ul>
                @if($data->currentPage() < $data->lastPage())
                    <p align="right">
                    <span>
                        <a href="javascript:void(0);" id="loadmore">
                            <font size="+2">查看更多&gt;&gt;</font></a>
                    </span>
                    </p>
                @endif
            </div>
        </div>
    </div>
@endsection

@section('style')
    <style type="text/css">
        html,body{margin:0;padding:0;}
        .iw_poi_title {color:#CC5522;font-size:14px;font-weight:bold;overflow:hidden;padding-right:13px;white-space:nowrap}
        .iw_poi_content {font:12px arial,sans-serif;overflow:visible;padding-top:4px;white-space:-moz-pre-wrap;word-wrap:break-word}
    </style>
@endsection

@section('script')
    <script type="text/javascript" src="http://v3.jiathis.com/code_mini/jia.js" charset="utf-8"></script>
    <script type="text/javascript">
        var current_page = "{{ $data->currentPage() }}" * 1;
        var last_page = "{{ $data->lastPage() }}" * 1;
        $('.m-topbanner,.m-pic-change').height($(window).height()-130);
        $(window).resize(function(){
            $('.m-topbanner,.m-pic-change').height($(window).height()-130);
        });

        $(function(){
            jQuery('#slide').slide({titOnClassName:'z-cur',vis:1,mainCell:'.m-showpic',autoPlay:true,effect:"fade",autoPage:true,titCell:".hd ul",interTime:3500,delayTime:2600});
            /*
             $("#nav").stick_in_parent({
             parent: "body",
             spacer: ".m-nav"
             });*/
        });

        $('#loadmore').bind('click', null, function (){
            if(current_page > last_page){ alert("没有更多信息了！");$('.nopic').css('display','none'); return false;}
            $.ajax({
                type:'get',
                url:'{{ $currentUrl }}',
                data:'page='+(current_page+1),
                dataType:'json',
                success: function(result)
                {
                    current_page = result.data.current_page;
                    last_page = result.data.last_page;

                    var content = result.data.content;
                    if (content) {
                        $(".nopic").before(content);
                        if(current_page>=last_page){
                            $('.nopic').css('display','none');
                        }
                    } else {
                        alert("没有更多信息了！");$('#loadmore').css('display','none'); return false;
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(errorThrown);
                }

            });
        })

    </script>
@endsection